home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / fgl105c.zip / 10-04.C < prev    next >
Text File  |  1991-05-05  |  1KB  |  63 lines

  1. #define VISUAL 0
  2. #define HIDDEN 1
  3.  
  4. int xmin[] = {  0, 96,192,  0, 96,192,  0, 96,192,  0, 96,192};
  5. int ymax[] = { 49, 49, 49, 99, 99, 99,149,149,149,199,199,199};
  6.  
  7. main()
  8. {
  9.    int new_mode, old_mode;
  10.    int frame, offset;
  11.    int i, x, y;
  12.  
  13.    /* initialize the video environment */
  14.  
  15.    new_mode = fg_bestmode(320,200,2);
  16.    if (new_mode < 0 || new_mode == 12) {
  17.       printf("This program requires a 320 ");
  18.       printf("x 200 color graphics mode.\n");
  19.       exit();
  20.       }
  21.    old_mode = fg_getmode();
  22.    fg_setmode(new_mode);
  23.    fg_allocate(HIDDEN);
  24.  
  25.    /* draw the background in the upper left corner */
  26.  
  27.    fg_setpage(HIDDEN);
  28.    fg_setcolor(1);
  29.    fg_rect(0,95,0,49);
  30.    fg_setcolor(15);
  31.    fg_move(48,25);
  32.    fg_ellipse(20,20);
  33.  
  34.    /* display the animated object against each background */
  35.  
  36.    fg_setcolor(10);
  37.    offset = -10;
  38.    for (i = 1; i < 12; i++) {
  39.       x = xmin[i];
  40.       y = ymax[i];
  41.       fg_transfer(0,95,0,49,x,y,HIDDEN,HIDDEN);
  42.       fg_setclip(x,x+95,0,199);
  43.       fg_clprect(x+offset,x+offset+19,y-29,y-20);
  44.       offset += 10;
  45.       }
  46.  
  47.    /* slide the object across the background three times */
  48.  
  49.    for (i = 0; i < 36; i++) {
  50.       frame = i % 12;
  51.       x = xmin[frame];
  52.       y = ymax[frame];
  53.       fg_transfer(x,x+95,y-49,y,112,124,HIDDEN,VISUAL);
  54.       fg_waitfor(2);
  55.       }
  56.  
  57.    /* restore the original video mode and return to DOS */
  58.  
  59.    fg_freepage(HIDDEN);
  60.    fg_setmode(old_mode);
  61.    fg_reset();
  62. }
  63.